package java_class_work.week07.thread;

import java.util.concurrent.FutureTask;

/**
 * @Auther: admin
 * @Date: 2022/10/25 15:04
 * @Description:
 */

public class ThreadDemo1 {
    public static void main(String[] args) {
        // 启动子线程1
        Thread thread01 = new Thread01();
        thread01.start();

        // 启动子线程2
        Runnable01 r01 = new Runnable01();
        Thread thread02 = new Thread(r01);
        thread02.start();
        // 或者 lambda表达式/内部类
        new Thread(() -> {
            for (int i = 0; i < 100; i++) {
                System.out.println("Lambda内部类线程" + i);
            }
        }).start();

        // 启动子线程3（使用较少 -》 不推荐）
        FutureTask<Integer> ft = new FutureTask<>(new Callable01());
        Thread thread03 = new Thread(ft);
        thread03.start();

        for (int i = 0; i < 1000; i++) {
            System.out.println("主线程：" + i);
        }
    }
}
